package com.zg.common.auth;

import lombok.Data;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
 * 判断请求是否携带AccessToken
 * @author Zxb
 */
@Aspect
@Component
@Data
public class NeedAccessTokenAspect {

	private AuthValidator authValidator;

	public NeedAccessTokenAspect(AuthValidator authValidator) {
		this.authValidator = authValidator;
	}

    @Pointcut("@annotation(com.zg.common.auth.NeedAccessToken)")
    public void pointCut(){}

    @Before("pointCut()")
    public void before(){
    	authValidator.hasAccessToken();
    }
}
